<template>
	<view class="content" v-if="authInfo">
		<view class="photo">
			<view class="list" @click="toLink('/technician/personal/authentication')">
				<image class="header" :src="authInfo.auth_image.image" v-if="!Array.isArray(authInfo.auth_image)"></image>
				<image class="header" :src="$util.imgurl('/imgs/technician/index/add.png')" v-else></image>
				<text>实人认证</text>
				<image class="icon" src="/static/technician/carema.png"></image>
			</view>
			<view class="list" @click="toWorkClothes">
				<image class="header" :src="authInfo.work_clothes_image.image" v-if="!Array.isArray(authInfo.work_clothes_image)"></image>
				<image class="header" :src="$util.imgurl('/imgs/technician/index/add.png')" v-else></image>
				<text>工装头像</text>
				<image class="icon" src="/static/technician/carema.png"></image>
			</view>
			<!-- /technician/personal/album -->
			<view class="list" @click="toAlbum">
				<image class="header" :src="authInfo.person_images[0].image" v-if="authInfo.person_images.length && authInfo.person_images[0].type == 'img'"></image>
				<image class="header" :src="authInfo.person_images[0].image + '?vframe/jpg/offset/8/'" v-else-if="authInfo.person_images.length && authInfo.person_images[0].type == 'video'"></image>
				<image class="header" :src="$util.imgurl('/imgs/technician/index/add.png')" v-else></image>
				<text>个人相册</text>
				<image class="icon" src="/static/technician/carema.png"></image>
			</view>
		</view>
		
		<view class="personal_list">
			<view class="list" @click="$util.toUrl('/technician/personal/qualificationsPhoto')">
				<view class="left">
					<image src="/static/technician/list_icon_0.png"></image>
					<view class="title">资质照片</view>
					<view class="tag">
						<text :id="!Array.isArray(authInfo.id_card_image_z) && !Array.isArray(authInfo.id_card_image_f) ? 'complate' : ''">身份证</text>
						<text :id="!Array.isArray(authInfo.seniority_image) ? 'complate' : ''">从业资质</text>
						<text :id="!Array.isArray(authInfo.health_certificate) ? 'complate' : ''">健康证</text>
					</view>
				</view>
				<view class="right">
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
			<view class="list" style="padding-bottom: 0; border: 0;" @click="$util.toUrl('/technician/info/resume')">
				<view class="left">
					<image src="/static/technician/list_icon_1.png"></image>
					<view class="title">个人简介</view>
				</view>
				<view class="right">
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
			<view class="textarea">
				<!-- {{authInfo.description || '还没有个人简介哦，赶快去编辑吧～'}} -->
			</view>
		</view>
		
		<view class="service_list">
			<view class="list" @click="$util.toUrl('/technician/info/service')">
				<view class="left">
					<image src="/static/technician/list_icon_2.png"></image>
					<view class="title">服务项目</view>
				</view>
				<view class="right">
					<view class="btn">立即设置</view>
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
			<view class="list" @click="$util.toUrl('/technician/info/time')">
				<view class="left">
					<image src="/static/technician/list_icon_3.png"></image>
					<view class="title">服务时间</view>
					<text v-if="authInfo.available_days && authInfo.end_time && authInfo.start_time">{{authInfo.start_time}}-{{authInfo.end_time}} ({{authInfo.available_days.split(',').length}}天/周）</text>
				</view>
				<view class="right">
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
			<view class="list" @click="$util.toUrl('/technician/info/location')">
				<view class="left">
					<image src="/static/technician/list_icon_4.png"></image>
					<view class="title">接单位置</view>
				</view>
				<view class="right">
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
			<view class="list no_border" @click="$util.toUrl('/technician/info/change')">
				<view class="left">
					<image src="/static/technician/list_icon_5.png"></image>
					<view class="title">接单手机</view>
				</view>
				<view class="right">
					<text>{{phone || '未绑定手机号'}}</text>
					<uni-icons type="forward" :size="20" color="#333333"></uni-icons>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone:'',
				authInfo:'',
			}
		},
		methods: {
			toLink(e){
				uni.navigateTo({
					url:e
				})
			},
			toWorkClothes(){
				if( !Array.isArray(this.authInfo.work_clothes_image)){
					uni.navigateTo({
						url:'/technician/personal/avatarPost?select=0'
					})
				}else {
					uni.navigateTo({
						url:'/technician/personal/avatarRequirements'
					})
				}
			},
			toAlbum(){
				if(this.authInfo.person_images.length){
					uni.navigateTo({
						url:'/technician/personal/avatarPost?select=1'
					})
				}else {
					uni.navigateTo({
						url:'/technician/personal/album'
					})
				}
			},
			getAuth(){
				let that = this
				this.request.httpTokenRequest({
					url: "technician.technician/getAuthInfo",
					method: "get"
				}, {}).then(res => {
					if (res.code == 0) {
						that.authInfo = res.data
						uni.setStorageSync('authInfo',that.authInfo)
						if(that.authInfo.person_images.length){
							let arr = that.authInfo.person_images[0].image.split('.')
							if(arr[arr.length-1] == 'jpg' || arr[arr.length-1] == 'jpeg' || arr[arr.length-1] == 'png' || arr[arr.length-1] == 'JPG' || arr[arr.length-1] == 'PNG'){
								that.authInfo.person_images[0].type = 'img'
							}else {
								that.authInfo.person_images[0].type = 'video'
							}
						}
					} else {
						this.$util.msg(res.msg)
						return
					}
				}, error => {})
			},
		},
		onLoad() {
			this.phone = uni.getStorageSync('user').mobile
		},
		onShow() {
			this.getAuth()
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 30rpx;
	}
	.photo {
		display: flex;
		align-items: center;
		justify-content: space-between;
		.list {
			width: 210rpx;
			height: 269rpx;
			background: #FFFFFF;
			border-radius: 14rpx;
			display: flex;
			align-items: center;
			flex-direction: column;
			justify-content: space-between;
			padding: 18rpx 20rpx 30rpx;
			box-sizing: border-box;
			position: relative;
			.header {
				width: 170rpx;
				height: 170rpx;
			}
			text {
				font-size: 28rpx;
				color: #08090A;
				line-height: 40rpx;
			}
			.icon {
				width: 40rpx;
				height: 40rpx;
				position: absolute;
				left: 50%;
				bottom: -20rpx;
				transform: translateX(-50%);
			}
		}
	}

	.personal_list {
		background: #FFFFFF;
		border-radius: 14rpx;
		padding: 0 30rpx;
		margin: 50rpx 0 33rpx;
		.list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 28rpx 0;
			border-bottom: 1rpx solid #E6E6E6;
			.left {
				display: flex;
				align-items: center;
				image {
					width: 40rpx;
					height: 40rpx;
				}
				.title {
					font-size: 30rpx;
					color: #08090A;
					line-height: 42rpx;
					margin: 0 40rpx 0 13rpx;
				}
				.tag {
					display: flex;
					align-items: center;
					text {
						width: 100rpx;
						height: 40rpx;
						background: #F4F4F4;
						border-radius: 4rpx;
						font-size: 22rpx;
						color: #08090A;
						line-height: 40rpx;
						text-align: center;
						margin: 0 5rpx;
					}
					#complate {
						background: rgba(40,108,219,0.1);
						color: #2A6EDC;
					}
				}
			}
		}
		.textarea {
			font-size: 22rpx;
			color: #8F8F8F;
			line-height: 30rpx;
			margin-top: 14rpx;
			padding-left: 54rpx;
			padding-bottom: 30rpx;
		}
	}
	
	.service_list {
		background: #FFFFFF;
		border-radius: 14rpx;
		padding: 0 30rpx;
		.list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 28rpx 0;
			border-bottom: 1rpx solid #E6E6E6;
			.left {
				display: flex;
				align-items: center;
				image {
					width: 40rpx;
					height: 40rpx;
				}
				.title {
					font-size: 30rpx;
					color: #08090A;
					line-height: 42rpx;
					margin: 0 40rpx 0 13rpx;
				}
				text {
					font-size: 22rpx;
					color: #A6A6A6;
					line-height: 30rpx;
					margin-left: 20rpx;
				}
			}
			.right {
				display: flex;
				align-items: center;
				.btn {
					width: 120rpx;
					height: 40rpx;
					background: #EE2131;
					border-radius: 20rpx;
					font-size: 22rpx;
					color: #FFFFFF;
					line-height: 40rpx;
					text-align: center;
					margin-right: 10rpx;
				}
				text {
					font-size: 30rpx;
					color: #08090A;
					line-height: 42rpx;
				}
			}
		}
		
	}

</style>
